/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ru.jSkyRoom.selector;

import java.util.Collection;
import ru.jSkyRoom.factory.FilterFactory;
import ru.jSkyRoom.factory.MajorMatcherFactory;
import ru.jSkyRoom.filter.Filter;
import ru.jSkyRoom.interfaces.major.Major;
import ru.jSkyRoom.support.RegexFactory;
import ru.rakev.matcher.Matcher;

/**
 *
 * @author Rakev
 */
public abstract class AbstractFromModByEdidSelector<T extends Major> implements SelectorByEdid<T> {

    protected abstract Collection<T> getExistMajors();

    @Override
    public Collection<T> select(String regexEdid) {
        MajorMatcherFactory matcherFactory = MajorMatcherFactory.create();
        Matcher<T> regexMatcher = matcherFactory.create(regexEdid);
        Filter<T> filter = FilterFactory.create().create(regexMatcher);
        Collection<T> selected = filter.filter(getExistMajors());
        return selected;
    }

    @Override
    public Collection<T> select(String... regexEdids) {
        String totalRegex = new RegexFactory().anyOf(regexEdids);
        return select(totalRegex);
    }

    @Override
    public Collection<T> select(Collection<String> regexEdids) {
        String totalRegex = new RegexFactory().anyOf(regexEdids);
        return select(totalRegex);
    }
}
